#include "sessionfactory.h"
#include "objpool.h"
#include <stdlib.h>

SessionFactory* sessionFactory_build(size_t session_len, size_t count) {
	size_t factory_size = sizeof(SessionFactory);
	SessionFactory *factory = (SessionFactory *) malloc(factory_size);

	struct obj_pool *sessions = objpool_build(session_len, count);

	factory->session_pool = sessions;
	return factory;
}

int sessionFactory_release(SessionFactory *factory) {
	objpool_release(factory->session_pool);
	free(factory);
	return 0;
}

AppSession* session_new(SessionFactory *factory) {
	AppSession *session_hdl = (struct appSession *) object_new(
			factory->session_pool);
	return session_hdl;
}
int session_del(SessionFactory *factory, AppSession *session) {
	int ret_a = object_del(factory->session_pool, session);
	return ret_a;
}
